package com.hotcars.controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.hotcars.dao.CarDao;
import com.hotcars.model.Car;

/**
 * Servlet implementation class CarsServlet
 */
public class CarsServlet extends HttpServlet {
	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		CarDao dao = new CarDao();
		List<Car> cars = dao.getCars();
		request.setAttribute("cars", cars);
		
		RequestDispatcher view = request.getRequestDispatcher("/cars.jsp");
		view.forward(request, response);
	}

}
